/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUINuevoProyecto.java
 *
 * Created on 28-dic-2010, 22:10:19
 */

package interfaz;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author Ruben
 */
public class GUINuevoProyecto extends javax.swing.JDialog {
    private String directorio;
    private String nombreProyecto;
    private String seleccion;

    /** Creates new form GUINuevoProyecto */
    public GUINuevoProyecto(java.awt.Frame parent, boolean modal,String seleccion) {
        super(parent, modal);
        initComponents();
        this.seleccion = seleccion;
    }

    public String getDirectorio(){
        return directorio;
    }

    public String getNombreProyecto(){
        return nombreProyecto;
    }

    public String getSeleccion(){
        return seleccion;
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        _btn_ok = new javax.swing.JButton();
        _btn_cancel = new javax.swing.JButton();
        _lbl_directorio = new javax.swing.JLabel();
        _lbl_nombreProyecto = new javax.swing.JLabel();
        _txt_directorio = new javax.swing.JTextField();
        _txt_nombreProyecto = new javax.swing.JTextField();
        _btn_directorio = new javax.swing.JButton();

        jLabel1.setText("jLabel1");

        jLabel2.setText("jLabel2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Nuevo Proyecto Nessy");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Nuevo Proyecto Nessy");

        _btn_ok.setText("OK");
        _btn_ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _btn_okActionPerformed(evt);
            }
        });

        _btn_cancel.setText("Cancel");
        _btn_cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _btn_cancelActionPerformed(evt);
            }
        });

        _lbl_directorio.setText("Directorio Proyecto:");

        _lbl_nombreProyecto.setText("Nombre del Proyecto");

        _btn_directorio.setText("...");
        _btn_directorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _btn_directorioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(72, 72, 72)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(79, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(_lbl_nombreProyecto)
                            .addComponent(_lbl_directorio))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(_btn_ok, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(_txt_directorio, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(_btn_directorio, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(_txt_nombreProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addComponent(_btn_cancel)))
                .addGap(57, 57, 57))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_lbl_directorio)
                    .addComponent(_btn_directorio)
                    .addComponent(_txt_directorio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_lbl_nombreProyecto)
                    .addComponent(_txt_nombreProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_btn_ok)
                    .addComponent(_btn_cancel))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void _btn_okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__btn_okActionPerformed
        if(_txt_directorio.getText().equals("") || _txt_nombreProyecto.getText().equals("")){
            JOptionPane.showMessageDialog(this, "Tienes que introducir el directorio y el nombre de proyecto", "Error" , JOptionPane.INFORMATION_MESSAGE);
        }
        else{
            directorio = _txt_directorio.getText();
            nombreProyecto = _txt_nombreProyecto.getText();
            seleccion = "ok";
            this.dispose();
        }
    }//GEN-LAST:event__btn_okActionPerformed

    private void _btn_directorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__btn_directorioActionPerformed
        JFileChooser chooser;
        chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("Selecciona el directorio donde se creará el proyecto Nessy");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setAcceptAllFileFilterUsed(false);
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            directorio = chooser.getSelectedFile().getPath();
            _txt_directorio.setText(directorio);
        }
    }//GEN-LAST:event__btn_directorioActionPerformed

    private void _btn_cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__btn_cancelActionPerformed
        seleccion="cancel";
        this.setVisible(false);
        this.dispose();
    }//GEN-LAST:event__btn_cancelActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton _btn_cancel;
    private javax.swing.JButton _btn_directorio;
    private javax.swing.JButton _btn_ok;
    private javax.swing.JLabel _lbl_directorio;
    private javax.swing.JLabel _lbl_nombreProyecto;
    private javax.swing.JTextField _txt_directorio;
    private javax.swing.JTextField _txt_nombreProyecto;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables

}
